import React,{ Component } from 'react'
import { connect } from 'react-redux'
import Navbar from '../components/Navbar'
import { validateToken } from '../actions/home'
import SettingForm from '../components/SettingForm'

class Setting extends Component {

  componentWillMount(){
    const { dispatch } = this.props
    if (this.props.home.login === true && this.props.home.token !== null) {
      dispatch(validateToken(dispatch,this.props.home.token))
    }
  }

  render(){
    return (
      <div>
      <Navbar />
      <SettingForm />
      </div>
    )
  }
}

const mapStateToProps = (state) => {
  return {
    home: state.home
  }
}

export default connect(mapStateToProps)(Setting)
